 /*
  *@author zhaozhi3758
  *
  */
 
    var show_goods_layer = 'order_goods_layer';
    var goods_hash_table = new Object;
    var timer = new Object; 
    var Browser = new Object();

    Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined');
    Browser.isIE = window.ActiveXObject ? true : false;
    Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != - 1);
    Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != - 1);
    Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != - 1);

   /**
     *
     */
    if (Browser.isIE)
    {
        window.attachEvent("onload", bind_order_event);
    }
    else
    {
        window.addEventListener("load", bind_order_event, false);
    }

//--------------------
var Utils = new Object();

Utils.$ = function(name)
{
    return document.getElementById(name);
}


Utils.fixEvent = function(e)
{
  var evt = (typeof e == "undefined") ? window.event : e;
  return evt;
}

Utils.srcElement = function(e)
{
  if (typeof e == "undefined") e = window.event;
  var src = document.all ? e.srcElement : e.target;
  return src;
}


Utils.x = function(e)
{    
     var body = document.documentElement || document.body; 
	return Browser.isIE?event.x + body.scrollLeft - 2:e.pageX;
}

Utils.y = function(e)
{ 
	    var body = document.documentElement || document.body;
		return Browser.isIE?event.y +  body.scrollTop  - 2:e.pageY;
}

Utils.request = function(url, item)
{
	var sValue=url.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"));
	return sValue?sValue[1]:sValue;
}


function rowindex(tr)
{
  if (Browser.isIE)
  {
    return tr.rowIndex;
  }
  else
  {
    table = tr.parentNode.parentNode;
    for (i = 0; i < table.rows.length; i ++ )
    {
      if (table.rows[i] == tr)
      {
        return i;
      }
    }
  }
}

function getPosition(o){
    var t = o.offsetTop;
    var l = o.offsetLeft;
    while(o = o.offsetParent)
    {
        t += o.offsetTop;
        l += o.offsetLeft;
    }
    var pos = {top:t,left:l};
    return pos;
}

  function bind_order_event()
    {
        var order_seq = 0;
        while(true)
        {
            var order_sn = Utils.$('order_'+order_seq);
            if (order_sn)
            {
                order_sn.onmouseover = function(e)
                {
                    try
                    {
                        window.clearTimeout(timer);
                    }
                    catch(e)
                    {
                    }
                    var order_id = Utils.request(this.href, 'order_id');//get order_id from  list page                    
                    // alert(order_id);
                    show_order_goods(e, order_id, show_goods_layer);
                }
                order_sn.onmouseout = function(e)
                {
                    hide_order_goods(show_goods_layer)
                }
                order_seq++;
            }
            else
            {
                break;
            }
        }
    } 
    
    
   /**
     * @return void
     */
    function show_order_goods(e, order_id, layer_id)
    {
        create_goods_layer(layer_id);
        $layer_id = Utils.$(layer_id);
        $layer_id.style.top = (Utils.y(e) + 12) + 'px';
        $layer_id.style.left = (Utils.x(e) + 12) + 'px';
        if (typeof(goods_hash_table[order_id]) == 'object')
        {
            response_goods_info(goods_hash_table[order_id]);
        }
        else
        {
             $layer_id.innerHTML = "<img src='/program/admin/images/wait.gif' border='0'><span style='font-size:12px;'>加载中，请稍后...</span>";
             var data = Math.round(Math.random() * 10000); 
             var url="goodsAjax.jsp?order_id="+order_id+"&data="+data;
              response_goods_info(url);
        }
    }
    
   /**
     * @return void
     */
    function create_goods_layer(id)
    {
        if (!Utils.$(id))
        {
            var n_div = document.createElement('DIV');
            n_div.id = id;
            n_div.className = 'order-goods';
            document.body.appendChild(n_div);
            Utils.$(id).onmouseover = function()
            {
                window.clearTimeout(window.timer);
            }
            Utils.$(id).onmouseout = function()
            {
                hide_order_goods(id);
            }
        }
        else
        {
            Utils.$(id).style.display = '';
        }
    }   
   
   /**
     * @return void
     */
    function hide_order_goods(layer_id)
    {
        $layer_id = Utils.$(layer_id);
        window.timer = window.setTimeout('$layer_id.style.display = "none"', 500);
    } 
    
  
    function response_goods_info(url)
    {
         /*$.ajax({
						  url:url,
						  cache: false,
						  success: function(html){
						     Utils.$(show_goods_layer).innerHTML =html;
						  }
					});*/
					
				 var myAjax = new Ajax.Updater(Utils.$(show_goods_layer),url,{ 
				   method : 'post', 
				   evalScripts : true 
		    }); 
    }    
         